'use strict';
// Copyright 2014 Blueant Inc. All Rights Reserved.

/**
 * @fileoverview 生存奖励子项
 * @author sundbcn@gmail.com (sun debing)
 */

var moment = require('moment');
var mongoose = require('mongoose');

///////////////////////////////////////////////////////////
/**
 * 奖励
 * @type {mongoose}
 */
var waveItemSchema = new mongoose.Schema({
    //奖励
    reward: {
        type: Number,
        default: 0
    },

    //奖励类型
    reward_type: {
        type: Number,
        default: 0
    },

    // 奖励数量
    reward_num: {
        type: Number,
        default: 0
    },

    // 奖励值
    reward_value: {
        type: Number,
        default: 0
    },

    // 孔
    hole_num: {
        type: Number,
        default: 0
    }
});

if (!waveItemSchema.options.toJSON) {
    waveItemSchema.options.toJSON = {};
}

/* jshint unused:false */
waveItemSchema.options.toJSON.transform = function (doc, ret) {
    delete ret._id;
    delete ret.__v;
};

///////////////////////////////////////////////////////////
var rewardItemSchema = new mongoose.Schema({
    // 波数
    wave: {
        type: Number,
        require: true
    },

    // 奖励列表
    wave_reward_list: [waveItemSchema]
});

/**
 * 获取生存的id
 * @return {[type]} [description]
 */
rewardItemSchema.methods.getSurviveId = function () {
    return this.survive_id;
};

rewardItemSchema.methods.addAttack = function () {

};

rewardItemSchema.methods.getAttackNum = function () {
    return this.attack_list.length;
};

if (!rewardItemSchema.options.toJSON) {
    rewardItemSchema.options.toJSON = {};
}
/* jshint unused:false */
rewardItemSchema.options.toJSON.transform = function (doc, ret) {
    delete ret.__v;
    delete ret._id;
};

module.exports = rewardItemSchema;
